<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #big {
        width: 400px;
        height: 400px;
        margin: 200px 0 0 100px;
        border: solid;
        position: relative;
      }

      #small {
        width: 100px;
        height: 100px;
        background-color: rgb(117, 110, 101);
        position: absolute;
      }
    </style>
  </head>
  <body>
    <div id="big">
      <div id="small"></div>
    </div>
    <script>
      const big = document.getElementById("big");
      const small = document.getElementById("small");
      const { x, y } = big.getBoundingClientRect();
      big.onclick = function (e) {
        small.style.left = e.clientX - x + "px";
        small.style.top = e.clientY - y + "px";
      };
    </script>
  </body>
</html>
